//package com.shiro.shiro_demo.realm;
//
//import com.shiro.shiro_demo.entity.CmfzAdmin;
//import com.shiro.shiro_demo.mapper.CmfzAdminMapper;
//import org.apache.shiro.authc.*;
//import org.apache.shiro.realm.AuthenticatingRealm;
//import org.springframework.beans.factory.annotation.Autowired;
//
//public class AuthenRealm extends AuthenticatingRealm {
//
//    @Autowired
//    private CmfzAdminMapper mapper;
//
//    @Override
//    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
//        //        1.从令牌中获取用户名
//        UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) authenticationToken;
//        String username = usernamePasswordToken.getUsername();
//
//        //根据传入对象登录账号查询对象
//        CmfzAdmin user =
//                mapper.selectUserName(username);
//
//        if (user != null) {
//            /**
//             * 第一个参数
//             */
//            return  new SimpleAuthenticationInfo(user.getUsername(),user.getPassword(),this.getName());
//        }
//        return null;
//    }
//
//}
